package cn.changhong.user.controller;

import cn.changhong.user.aop.ResultBean;
import cn.changhong.user.model.vo.RoleVO;
import cn.changhong.user.service.RoleService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zz
 * @Date
 **/
@RestController
@RequestMapping("user_manage/role")
public class RoleController {
    @Autowired
    RoleService roleService;

    @RequestMapping(value = "superAdmin/listRole",method = RequestMethod.GET)
    @CrossOrigin
    public ResultBean<List<RoleVO>> listRole(){
        return new ResultBean(roleService.listRole());
    }

    @RequestMapping(value = "superAdmin/freezeRole",method = RequestMethod.PUT)
    @CrossOrigin
    public ResultBean<Integer> freezeRole(@RequestParam("roleId")int roleId){
        return new ResultBean(roleService.freezeRole(roleId));
    }

    @RequestMapping(value = "superAdmin/addRole",method = RequestMethod.POST)
    @CrossOrigin
    public ResultBean<Integer> freezeRole(@RequestBody JSONObject body){
        return new ResultBean(roleService.addRole(body));
    }

    @RequestMapping(value = "superAdmin/removeRole",method = RequestMethod.DELETE)
    @CrossOrigin
    public ResultBean<Integer> removeRole(@RequestParam("roleId")int roleId){
        return new ResultBean(roleService.removeRole(roleId));
    }
}
